import socket
import threading

from fileT import send_thread

class Listener(threading.Thread):
   sock = None
   port = 1338

   def __init__(self, port):
      threading.Thread.__init__(self)
      self.port = port
      print "listenT port: "+str(port)
      self.sock = socket.socket()
      self.sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)

   def run(self):
      self.sock.bind(('', self.port))
      self.sock.listen(5)
      while 1:
         client_sock,address = self.sock.accept()
         sender = send_thread(client_sock, address)
         sender.start()

